<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\policy\logic;

use plugin\saiadmin\basic\BaseLogic;
use plugin\saiadmin\exception\ApiException;
use plugin\saiadmin\utils\Helper;
use app\policy\model\Policy;

/**
 * 政策列表逻辑层
 */
class PolicyLogic extends BaseLogic
{
    /**
     * 构造函数
     */
    public function __construct()
    {
        $this->model = new Policy();
    }
    public function getPolicy($userId,$limit){
     return $this->model
            ->rightJoin('eb_collection', 'eb_policy.policy_id = eb_collection.collection_id')
            ->field('eb_policy.policy_id,eb_policy.policy_title,eb_policy.policy_image,eb_policy.is_top,eb_policy.issuing_unit,eb_policy.policy_details,eb_policy.create_time')
            ->where('eb_collection.user_id', $userId)
            ->where('eb_collection.type', 1)
             ->whereNull('eb_policy.delete_time')
            // 修正拼写错误，将 ceeate_time 改为 create_time
            ->order('eb_collection.create_time desc')
            ->paginate($limit);
    }


}
